package com.dy.system.service.impl;

import java.util.List;
import com.dy.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dy.system.mapper.InspectionReportMapper;
import com.dy.system.domain.InspectionReport;
import com.dy.system.service.IInspectionReportService;
import org.springframework.util.CollectionUtils;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author anps
 * @date 2022-08-04
 */
@Service
public class InspectionReportServiceImpl implements IInspectionReportService{
    @Autowired
    private InspectionReportMapper inspectionReportMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public InspectionReport selectInspectionReportById(Long id){
        return inspectionReportMapper.selectInspectionReportById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param inspectionReport 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<InspectionReport> selectInspectionReportList(InspectionReport inspectionReport){
        return inspectionReportMapper.selectInspectionReportList(inspectionReport);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param inspectionReport 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertInspectionReport(InspectionReport inspectionReport){
        inspectionReport.setCreateTime(DateUtils.getNowDate());
        return inspectionReportMapper.insertInspectionReport(inspectionReport);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param inspectionReport 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateInspectionReport(InspectionReport inspectionReport){
        inspectionReport.setUpdateTime(DateUtils.getNowDate());
        return inspectionReportMapper.updateInspectionReport(inspectionReport);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteInspectionReportByIds(Long[] ids){
        return inspectionReportMapper.deleteInspectionReportByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteInspectionReportById(Long id){
        return inspectionReportMapper.deleteInspectionReportById(id);
    }

    @Override
    public InspectionReport selectInspectionReportByInsId(Long institutionId, int session) {
        return inspectionReportMapper.selectInspectionReportByInsId(institutionId,session);
    }

    @Override
    public InspectionReport selectInspectionReportDp(InspectionReport inspectionReport) {
        List<InspectionReport> inspectionReportList = inspectionReportMapper.selectInspectionReportList(inspectionReport);
        if (CollectionUtils.isEmpty(inspectionReportList)){
            return null;
        }
        return inspectionReportList.get(0);
    }
}
